package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.vo.CommentTreeVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

@Getter
@Setter@ToString
public class FriendCircle extends BaseDomain{

    public static final Boolean IS_PUBLIC = true;   //公开
    public static final Boolean NO_PUBLIC = false;  //不公开

    /**
     * 用户id
     */
    private User user;

    /**
     * 朋友圈内容
     */
    private String content;

    /**
     * 图片
     */
    private String imgUrls;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date creatTime;

    /**
     * 是否公开(默认公开)
     */
    private Boolean isPublic = true;

    /**
     * 通过切割取出每张图片地址
     *
     * @return
     */
    public String[] getImgUrlsArr() {
        if (StringUtils.hasLength(imgUrls)) {
            return imgUrls.split(";");
        }
        return null;
    }

    private List<CommentTreeVo> commentTreeVos; //二级评论
}